package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.MatRepairFlow;
import com.indusfo.spc.service.MatRepairFlowService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author liub
 * @Date 2019/11/25 10:45
 * @Version 1.0
 */

@Controller
@RequestMapping(value = "/service/matRepairFlow")
public class MatRepairFlowController {

    @Autowired
    private MatRepairFlowService matRepairFlowService;

    /**
     * 查询
     */
    @RequestMapping(value = "/queryMatRepairFlow")
    @ResponseBody
    public JSONObject queryMatRepairFlow(MatRepairFlow matRepairFlow) {
        JSONObject json = matRepairFlowService.queryMatRepairFlow(matRepairFlow);
        return json;
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/insertMatRepairFlow", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject insertMatRepairFlow(MatRepairFlow matRepairFlow) {
        JSONObject json = matRepairFlowService.insertMatRepairFlow(matRepairFlow);
        return json;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/updateMatRepairFlow", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject updateMatRepairFlow(MatRepairFlow matRepairFlow) {
        JSONObject json = matRepairFlowService.updateMatRepairFlow(matRepairFlow);
        return json;
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/deleteMatRepairFlow", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject deleteMatRepairFlow(@RequestParam("matRepairFlowIds") List<Integer> matRepairFlowIds, Integer dataState) {
        dataState = 2;
        JSONObject json = matRepairFlowService.deleteMatRepairFlow(matRepairFlowIds, dataState);
        return json;
    }

    /**
     * 启停
     */
    @RequestMapping(value = "/definedMatRepairFlow", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject definedMatRepairFlow(@RequestParam("matRepairFlowIds") List<Integer> matRepairFlowIds, Integer dataState) {
        JSONObject json = matRepairFlowService.deleteMatRepairFlow(matRepairFlowIds, dataState);
        return json;
    }
}
